package com.hgw.ordinary.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Description:
 * @date 2022/10/7 09:44
 * @author itLaboratory-yanAn
 */
@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {

    @Value("${file.staticPatternPath}")
    private String staticPatternPath;

    @Value("${file.path}")
    private String uploadFolder;

    /**
     * SpringBoot中封装的SpringMVC配置文件上传的额外的静态资源服务的配置
     *
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(staticPatternPath + "/**").addResourceLocations("file:" + uploadFolder + "/");
    }
}
